package com.maun.test;

import com.maun.test_entity.Endpoint;
import com.maun.maun.Maun;
import com.maun.maun.MaunFactory;
import com.maun.exception.MarshalerException;
import java.io.FileOutputStream;
import java.util.Properties;


public class Main {

    //private final static Logger LOGGER = Logger.getLogger(Main.class.getName());

    public static void main(String[] args) throws MarshalerException {
            Properties properties = new Properties();
            
            properties.setProperty("mysql.database", "maun");
            properties.setProperty("mysql.host", "localhost");
            properties.setProperty("mysql.port", "3306");
            properties.setProperty("mysql.username", "root");
            properties.setProperty("mysql.password", "adminadmin");
            
            //properties.store(new FileOutputStream("config.properties"), "Database connection settings");
            
            Maun maunMysql = MaunFactory.getInstance("mysql", properties);
            maunMysql.initSchema(Endpoint.class);

            Endpoint endpoint1 = new Endpoint();

            endpoint1.setId(1);
            endpoint1.setName("name1");
            endpoint1.setVersion((short) 1);
            endpoint1.setUrl("http://www.url1.com");
            endpoint1.setBool(true);

            maunMysql.save(endpoint1);
           
            Endpoint endpoint2 = new Endpoint();

            endpoint2.setId(2);
            endpoint2.setName("name2");
            endpoint2.setVersion((short) 2);
            endpoint2.setUrl("http://www.url2.com");
            endpoint2.setBool(false);

            maunMysql.save(endpoint2);
            maunMysql.close();
    }
}
